package com.ruoyi.module.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.Date;

/**
 * 短信发送日志对象 sms_log
 *
 * @author fubojin
 * @date 2024-12-9
 */
@Data
@ApiModel(value = "短信发送日志")
@AllArgsConstructor
@NoArgsConstructor
public class SmsLog {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @ApiModelProperty(value = "主键")
    private Long id;

    /**
     * 响应信息
     */
    @Excel(name = "响应信息")
    @ApiModelProperty(value = "响应信息")
    private String msg;

    /**
     * 请求参数
     */
    @Excel(name = "请求参数")
    @ApiModelProperty(value = "请求参数")
    private String param;

    /**
     * 模板id
     */
    @Excel(name = "模板id")
    @ApiModelProperty(value = "模板id")
    private Integer templateId;

    /**
     * 发送结果
     */
    @Excel(name = "发送结果")
    @ApiModelProperty(value = "发送结果")
    private Integer result;

    /**
     * 电话号码
     */
    @Excel(name = "电话号码")
    @ApiModelProperty(value = "电话号码")
    private String phone;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(hidden = true)
    private Date createTime;

    public SmsLog(SmsSingleSenderResult result, int templateId, String[] params, String phone) {
        this.msg = result.errMsg;
        this.result = result.result;
        this.templateId = templateId;
        this.param = Arrays.toString(params);
        this.phone = phone;
    }

}
